global keepers1982 ""


numlabel, add

drop if v5==2

drop if v2~=8

genl yr=1982
global keepers1982 $keepers1982 yr

genl id=v1
global keepers1982 $keepers1982 id

merge 1:1 v1 using "$sourcedatadir/se/vu82ink.dta" /* Note: duplicate observations deleted from the file first using */
/* duplicates drop */
drop if _merge==2

genl income=V910
genl income3=income
centile income, c(33 66 100)
replace income3=0 if income<=r(c_1)
centile income, c(33 66 100)
replace income3=1 if income>r(c_1) & income<=r(c_2)
centile income, c(33 66 100)
replace income3=2 if income>r(c_2) & income<=r(c_3)
global keepers1982 $keepers1982 income3

genl pid_ce=(v154==33 & v155==1)
replace pid_ce=. if v153==.
global keepers1982 $keepers1982 pid_ce

gen pid_gov=((v154==33 | v154==44 | v154==55) & v155==1)
replace pid_gov=. if v153==.
global keepers1982 $keepers1982 pid_gov

genl vote_ce=v170
recode vote_ce 33=1 .=. else=0
global keepers1982 $keepers1982 vote_ce

genl vote_gov=v170
recode vote_gov 33 44 55=1 .=. else=0
global keepers1982 $keepers1982 vote_gov


genl gpi=v27
replace gpi=abs(gpi-4)/3
global keepers1982 $keepers1982 gpi

genl degree=v190
recode degree 7=1 0/6 8=0 9=.
global keepers1982 $keepers1982 degree



// Class/occupation

gen class_resp_3cat = v183
recode class_resp_3cat 1/7=3 10/25=2 30/40=1 0=.
replace class_resp_3cat = . if class_resp_3cat > 40
label variable class_resp_3cat "Social class (3 cats.): higher value is higher class"
*label define LblClassGrade 1 "A: (Higher man.; prof." 2 "B: Lower man.; admin." 3 "C1A: Skilled; supervis. non-manu." 4 "C1B: Lower non-manu." 5 "C2: Skilled manu." 6 "D: Unskilled manu."
*label values class_head_grade LblClassGrade
global keepers1982 $keepers1982 class_resp_3cat

gen class_spou_3cat = v256
recode class_spou_3cat 1/7=3 10/25=2 30/40=1 0=.
replace class_spou_3cat = . if class_spou_3cat > 40
label variable class_spou_3cat "Social class (3 cats.): higher value is higher class"
*label define LblClassGrade 1 "A: (Higher man.; prof." 2 "B: Lower man.; admin." 3 "C1A: Skilled; supervis. non-manu." 4 "C1B: Lower non-manu." 5 "C2: Skilled manu." 6 "D: Unskilled manu."
*label values class_head_grade LblClassGrade
global keepers1982 $keepers1982 class_spou_3cat

gen class_reho_3cat_strata = v293
recode class_reho_3cat_strata 1=1 2=1 3=2 4=2 5=1 6=2 7=2 8=. 10=. 88=. 96=. 99=.
replace class_reho_3cat_strata = . if class_reho_3cat_strata > 40
label variable class_reho_3cat_strata "Social class (3 cats.): higher value is higher class"
*label define LblClassGrade 1 "A: (Higher man.; prof." 2 "B: Lower man.; admin." 3 "C1A: Skilled; supervis. non-manu." 4 "C1B: Lower non-manu." 5 "C2: Skilled manu." 6 "D: Unskilled manu."
*label values class_head_grade LblClassGrade
global keepers1982 $keepers1982 class_reho_3cat_strata


gen male = v290
recode male 1=1 2=0
global keepers1982 $keepers1982 male

gen married = v253
recode married 1=1 2/3=0 6=. 9=.
global keepers1982 $keepers1982 married

gen unionmem_resp = v219
recode unionmem_resp 1/4=1 5=0
global keepers1982 $keepers1982 unionmem_resp

*gen unionmem_spou = v259
*recode unionmem_spou 1/4=1 .=0
*global keepers1979 $keepers1979 unionmem_spou



// Pascal/SM moderators


 gen party_ID=. 
   replace party_ID=1 if v153==1 & v154==11
   replace party_ID=2 if v153==1 & v154==22
   replace party_ID=3 if v153==1 & v154==33
   replace party_ID=4 if v153==1 & v154==44
  
   replace party_ID=6 if v153==1 & v154==66
   replace party_ID=7 if v153==1 & v154==87

   replace party_ID=8 if v153==1 & v154==88
   
   replace party_ID=9 if v153==1 & v154==12
 
   replace party_ID=10 if v153==1 & v154==55
 
 replace party_ID=11 if v153==1 & v154==13
 replace party_ID=12 if v153==1 & v154==71
 replace party_ID=13 if v153==1 & v154==72
 replace party_ID=14 if v153==1 & v154==73
replace party_ID=15 if v153==1 & v154==82
replace party_ID=16 if v153==1 & v154==14
replace party_ID=17 if v153==1 & v154==15
replace party_ID=18 if v153==1 & v154==9

 lab def party_ID 1 "v‰nsterpartiet kom " 2 "socialdemokraterna" 3"centerpartiet" 4"folkpartiet" 5"hˆgerpartiet" 6"kristen demokratis" 7 "other" 8 "will not answer"9 " kommunistiska fˆrbundet marxist-len" 10 " moderata samlingspartiet " 11 "sveriges kommunis" 12 "borgerligt "  13 "FC+C" 14 "lokal borgerlig" 15 "skÂnepartiet" 16 "kommunistiska arbetarefˆrbundet" 17 "vpk, apk, kpmlr, skp, kaf" 18 "grˆnt parti" 19 "ny demokrati"
 lab val party_ID party_ID
  tab party_ID, m
 tab party_ID v154, m



 foreach var of varlist  v108 v109 v110 v114{
        gen Z`var'=`var'
		replace Z`var'=5 if `var'==1
		replace Z`var'=4 if `var'==2
		replace Z`var'=3 if `var'==8 | `var'==3
		replace Z`var'=2 if `var'==4
		replace Z`var'=1 if `var'==5
		replace Z`var'=(Z`var'-1)/4
		tab Z`var' `var', m
  }

rename Zv108 cut_public
lab var cut_public "1=good idea to reduce size of public sector"
    
 rename Zv109 transfer
lab var transfer "1=good idea to transfer business profit to union funds"

rename Zv110 socialize
lab var socialize "1=good idea to socialize large industries" 

rename Zv114 cut_benefit
lab var cut_benefit "1=good idea to reduce social benefits"


 foreach var of varlist  v145 v147 v148{
        gen Z`var'=`var'/10
		replace Z`var'=0.5 if Z`var'>1
		replace Z`var'=. if `var'==.
			tab Z`var' `var', m
  }

rename Zv145 m_market_oriented
lab var m_market_oriented "1=favor move toward more free-market"

rename Zv147 m_less_regulation
lab var m_less_regulation "1=favor move toward less regulation"

rename Zv148 m_socialism
lab var m_socialism "1=favor move toward socialism"


 gen right=v165/10
replace right=0.50 if right>1 & right~=.
  tab right v165, m
  lab var right "1=far right"

gen transfer2=.
replace transfer2=1 if v125==1
replace transfer2=0.5 if v125==3 | v125==8
replace transfer2=0 if v125==5
replace transfer2=. if v125==6 | v125==9
lab var transfer2 "1=favor transfer business profit to union funds"
tab transfer2 v125, m


gen newspaper_politics=.
 replace newspaper_politics=0 if v23==1
 replace newspaper_politics=0.33 if v23==2
 replace newspaper_politics=0.66 if v23==3
 replace newspaper_politics=1 if v23==4
  replace newspaper_politics=0.5 if v23==8
    replace newspaper_politics=. if v23==0

tab newspaper_politics v23,m
 lab var newspaper_politics "1=read more politic articles"



foreach var of varlist m_market_oriented m_less_regulation  {
        
gen anti_`var'=.
replace anti_`var'=0 if `var'==1
replace anti_`var'=0.1 if `var'>=0.88 & `var'<=0.91 
replace anti_`var'=0.2 if `var'>=0.78 & `var'<=0.81 
replace anti_`var'=0.3 if `var'>=0.68 & `var'<=0.71 
replace anti_`var'=0.4 if `var'>=0.58 & `var'<=0.61 
replace anti_`var'=0.5 if `var'>=0.48 & `var'<=0.51 
replace anti_`var'=0.6 if `var'>=0.38 & `var'<=0.41 
replace anti_`var'=0.7 if `var'>=0.28 & `var'<=0.31 
replace anti_`var'=0.8 if `var'>=0.18 & `var'<=0.21 
replace anti_`var'=0.9 if `var'>=0.08 & `var'<=0.11 
replace anti_`var'=1 if `var'==0
  }
tab anti_m_market_oriented m_market_oriented ,m 
tab anti_m_less_regulation m_less_regulation, m



gen anti_socialize=.
replace anti_socialize=0 if socialize==1
replace anti_socialize=0.25 if socialize==0.75
replace anti_socialize=0.5 if socialize==0.5
replace anti_socialize=0.75 if socialize==0.25
replace anti_socialize=1 if socialize==0
tab anti_socialize socialize, m

gen anti_transfer =.
replace anti_transfer =0 if transfer ==1
replace anti_transfer =0.25 if transfer ==0.75
replace anti_transfer =0.5 if transfer ==0.5
replace anti_transfer =0.75 if transfer ==0.25
replace anti_transfer =1 if transfer ==0
tab anti_transfer  transfer , m


gen anti_transfer2=.
replace anti_transfer2=0 if transfer2==1
replace anti_transfer2=0.5 if transfer2==0.5
replace anti_transfer2=1 if transfer2==0
tab anti_transfer2 transfer2, m

gen anti_m_socialism=.
replace anti_m_socialism=0 if m_socialism==1
replace anti_m_socialism=0.1 if m_socialism>=0.88 & m_socialism<=0.91 
replace anti_m_socialism=0.2 if m_socialism>=0.78 & m_socialism<=0.81 
replace anti_m_socialism=0.3 if m_socialism>=0.68 & m_socialism<=0.71 
replace anti_m_socialism=0.4 if m_socialism>=0.58 & m_socialism<=0.61 
replace anti_m_socialism=0.5 if m_socialism>=0.48 & m_socialism<=0.51 
replace anti_m_socialism=0.6 if m_socialism>=0.38 & m_socialism<=0.41 
replace anti_m_socialism=0.7 if m_socialism>=0.28 & m_socialism<=0.31 
replace anti_m_socialism=0.8 if m_socialism>=0.18 & m_socialism<=0.21 
replace anti_m_socialism=0.9 if m_socialism>=0.08 & m_socialism<=0.11 
replace anti_m_socialism=1 if m_socialism==0
tab anti_m_socialism m_socialism, m

gen index_interest=(gpi+newspaper_politics )/2
global keepers1982 $keepers1982 index_interest

gen index_market_oriented=( anti_transfer+ anti_socialize+  m_market_oriented +anti_m_less_regulation+ right+ anti_transfer2)/6
global keepers1982 $keepers1982 index_market_oriented
